from die import Die
import plotly.express as px

die_1 = Die(20)
die_2 = Die(20)
results = []
for roll_num in range(50000000):
    result = die_1.roll() + die_2.roll()
    results.append(result)

# print(results)

# 开始分析结果

frequencies = []
poss_results = range(2,die_1.num_sides+die_2.num_sides+1)
for v in poss_results:
    frequency = results.count(v)
    frequencies.append(frequency)

# print(frequencies)

title = "胡绍康"
labels = {'x' : 'Result','y':'Frequency of Result'}
fig = px.bar(x = poss_results,y = frequencies,title = title , labels =labels)
fig.update_layout(xaxis_dtick = 1)
fig.show()